package cn.lyn4ever.cataccount.controller;

import cn.lyn4ever.cataccount.entity.User;
import cn.lyn4ever.cataccount.service.UserService;
import cn.lyn4ever.common.R;
import cn.lyn4ever.common.SecurityParameter;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("user")
public class UserController {

    /**
     * 服务对象
     */
    @Resource
    private UserService userService;

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @GetMapping("selectOne")
    public User selectOne(Integer id) {
        return this.userService.queryById(id);
    }


    /**
     * 用户登录功能，目前只支持使用手机号和密码登录
     * @return
     */
    @RequestMapping("login")
    public R login(User user) {
        return userService.login(user);
    }


    @RequestMapping("regist")
    public R regist(User user){
        System.out.println("aaa");
        return userService.registUser(user);
    }

}
